package com.sunzm.dbencrypteddynamic.controller;

import com.sunzm.dbencrypteddynamic.model.User;
import com.sunzm.dbencrypteddynamic.service.IUserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author SunZm
 * @since 2024-08-25
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private IUserService userService;

    @GetMapping("/{id}")
    public User findById(@PathVariable long id) {
        return userService.getUserById(id);
    }

    @PostMapping("/")
    public int add(@RequestBody User user) {
        return userService.saveUser(user);
    }

    @GetMapping("/")
    public List<User> findAll() {
        return userService.list();
    }
}
